<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>ColumnResult constructor</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="class.mysql-xdevapi-columnresult.html">« mysql_xdevapi\ColumnResult</a></li>
      <li style="float: right;"><a href="mysql-xdevapi-columnresult.getcharactersetname.html">ColumnResult::getCharacterSetName »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.mysql-xdevapi-columnresult.html">mysql_xdevapi\ColumnResult</a></li>
    <li>ColumnResult constructor</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="mysql-xdevapi-columnresult.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ColumnResult::__construct</h1>
  <p class="verinfo">(No version information available, might only be in Git)</p><p class="refpurpose"><span class="refname">ColumnResult::__construct</span> &mdash; <span class="dc-title">ColumnResult constructor</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mysql-xdevapi-columnresult.construct-description">
  <h3 class="title">说明</h3>
  <div class="constructorsynopsis dc-description">
   <span class="modifier">private</span> <span class="methodname"><strong>mysql_xdevapi\ColumnResult::__construct</strong></span>()</div>

  <p class="para rdfs-comment">
   Retrieve column metadata, such as its character set;
   this is instantiated by the RowResult::getColumns() method.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-mysql-xdevapi-columnresult.construct-parameters">
  <h3 class="title">参数</h3>
  <p class="para">此函数没有参数。</p>
 </div>


 <div class="refsect1 examples" id="refsect1-mysql-xdevapi-columnresult.construct-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-1602">
   <p><strong>示例 #1 <span class="function"><strong>mysql_xdevapi\ColumnResult::__construct()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$session&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mysql_xdevapi</span><span style="color: #007700">\</span><span style="color: #0000BB">getSession</span><span style="color: #007700">(</span><span style="color: #DD0000">"mysqlx://user:password@localhost"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$session</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">sql</span><span style="color: #007700">(</span><span style="color: #DD0000">"DROP&nbsp;DATABASE&nbsp;IF&nbsp;EXISTS&nbsp;nonsense"</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">execute</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$session</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">sql</span><span style="color: #007700">(</span><span style="color: #DD0000">"CREATE&nbsp;DATABASE&nbsp;nonsense"</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">execute</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$session</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">sql</span><span style="color: #007700">(</span><span style="color: #DD0000">"CREATE&nbsp;TABLE&nbsp;nonsense.numbers&nbsp;(hello&nbsp;int,&nbsp;world&nbsp;float&nbsp;unsigned)"</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">execute</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$session</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">sql</span><span style="color: #007700">(</span><span style="color: #DD0000">"INSERT&nbsp;INTO&nbsp;&nbsp;nonsense.numbers&nbsp;values&nbsp;(42,&nbsp;42)"</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">execute</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">$schema&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$session</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getSchema</span><span style="color: #007700">(</span><span style="color: #DD0000">"nonsense"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$table&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$schema</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getTable</span><span style="color: #007700">(</span><span style="color: #DD0000">"numbers"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$result1&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$table</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">select</span><span style="color: #007700">(</span><span style="color: #DD0000">'hello'</span><span style="color: #007700">,</span><span style="color: #DD0000">'world'</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">execute</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">//&nbsp;Returns&nbsp;an&nbsp;array&nbsp;of&nbsp;ColumnResult&nbsp;objects<br /></span><span style="color: #0000BB">$columns&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$result1</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getColumns</span><span style="color: #007700">();&nbsp;<br /><br />foreach&nbsp;(</span><span style="color: #0000BB">$columns&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$column</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"\nColumn&nbsp;label&nbsp;"&nbsp;</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$column</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getColumnLabel</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&nbsp;is&nbsp;type&nbsp;"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$column</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getType</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&nbsp;and&nbsp;is&nbsp;"</span><span style="color: #007700">,&nbsp;(</span><span style="color: #0000BB">$column</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">isNumberSigned</span><span style="color: #007700">()&nbsp;===&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">)&nbsp;?&nbsp;</span><span style="color: #DD0000">"Unsigned."&nbsp;</span><span style="color: #007700">:&nbsp;</span><span style="color: #DD0000">"Signed."</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #FF8000">//&nbsp;Alternatively<br /></span><span style="color: #0000BB">$result2&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$session</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">sql</span><span style="color: #007700">(</span><span style="color: #DD0000">"SELECT&nbsp;*&nbsp;FROM&nbsp;nonsense.numbers"</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">execute</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">//&nbsp;Returns&nbsp;an&nbsp;array&nbsp;of&nbsp;FieldMetadata&nbsp;objects<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$result2</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getColumns</span><span style="color: #007700">());</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程的输出类似于：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>

Column label hello is type 19 and is Signed.
Column label world is type 4  and is Unsigned.

Array
(
    [0] =&gt; mysql_xdevapi\FieldMetadata Object
        (
            [type] =&gt; 1
            [type_name] =&gt; SINT
            [name] =&gt; hello
            [original_name] =&gt; hello
            [table] =&gt; numbers
            [original_table] =&gt; numbers
            [schema] =&gt; nonsense
            [catalog] =&gt; def
            [collation] =&gt; 0
            [fractional_digits] =&gt; 0
            [length] =&gt; 11
            [flags] =&gt; 0
            [content_type] =&gt; 0
        )
    [1] =&gt; mysql_xdevapi\FieldMetadata Object
        (
            [type] =&gt; 6
            [type_name] =&gt; FLOAT
            [name] =&gt; world
            [original_name] =&gt; world
            [table] =&gt; numbers
            [original_table] =&gt; numbers
            [schema] =&gt; nonsense
            [catalog] =&gt; def
            [collation] =&gt; 0
            [fractional_digits] =&gt; 31
            [length] =&gt; 12
            [flags] =&gt; 1
            [content_type] =&gt; 0
        )
)
</pre></div>
   </div>
  </div>
 </div>


</div></div></div></body></html>